<?php
namespace frontend\controllers;

use Yii;
use common\models\Comment;
use yii\web\Controller;

class CommentController extends Controller
{

    public function actionAdd($id)
    {
        $comment = new  Comment();
    	$comment->post_id = $id;
    	$comment->comment = Yii::$app->request->post('comment');
    	$comment->created_at = time();
    	$comment->updated_at = time();
    	$comment->status = Comment::IS_VALID;
    	
    	if ($comment->save()) {
          return  $this->redirect(Yii::$app->request->referrer);
//             var_dump($comment->errors);
    	} else {
    	    return 'Error';
    	}
    }
}